﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using HandyControl.Controls;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using SoonCode.FocusTest.Api;
using SoonCode.FocusTest.Events;
using SoonCode.FocusTest.Models;

namespace SoonCode.FocusTest.ViewModels
{
    class WebBrowserViewModel:BindableBase
    {
        private string title;
        public string Title
        {
            get { return title; }
            set
            {
                title = value; 
                RaisePropertyChanged();
            }
        }
        private string url;
        public string Url
        {
            get { return url;}
            set
            {
                url=value;
                RaisePropertyChanged();
            }
        }

        private IEventAggregator _eventAggregator;

        public WebBrowserViewModel(IEventAggregator aggregator)
        {
            this._eventAggregator=aggregator;
            aggregator.GetEvent<OpenPageEvent>().Subscribe(OpenPage);
        }
        public void OpenPage(WebAppModel p)
        {
            Url = p.url;
            Title = p.title;

        }
    }
}
